﻿
CREATE PROCEDURE [dbo].[proc_discount_GetItem]
(
   @Id int,
   @CId int,
   @OId varchar(60)
)
AS
BEGIN
If @Id>0
	Select * From discount_list
	Where Id=@Id
	Order By ID Desc
Else If @CId>0
	Select Top 1 * From discount_list
	Where Diqu=@CId
	Order By ID Desc
Else
	Select Top 1 * From discount_list
	Where Diqu In(Select CompanyId From [Order] Where OId=@OId)
	Order By ID Desc
END